package com.example.unsafestop;

/**
 * @author:CrazyShaQiuShi
 * @email:3105334046@qq.com
 * @descript:
 * @version:1.0.0
 */
public class ReadObjectThread extends Thread {
    private User u;


    public User getU() {
        return u;
    }

    public void setU(User u) {
        this.u = u;
    }

    public ReadObjectThread(User u) {
        this.u = u;
    }

    @Override
    public void run() {
        while (true) {
            synchronized (u) {
                if (u.getId() != Integer.parseInt(u.getName())) {
                    System.out.println(u.toString());
                }
            }
            Thread.yield();
        }
    }
}
